<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'subcategory-form',
    'enableAjaxValidation' => false,
    'enableClientValidation' => true,
    'htmlOptions' => array(
        'class' => 'form-horizontal',
        'enctype' => 'multipart/form-data',
    ),
        ));
?>
<div class="row-fluid">
    <div class="span12">
        <!--PAGE CONTENT BEGINS-->
        <div class="control-group">
            <label class="control-label">Thứ tự hiện thị</label>
            <div class="controls">
                <?php echo $form->textField($model, "order", array('size' => 60, 'maxlength' => 100, 'class' => 'span5', 'placeholder' => 'Thứ tự hiện thị')); ?>
                <span class="help-inline"><?php echo $form->error($model, 'order'); ?></span>
            </div>
        </div>
        <?php
        $cate = MyFunctionCustom::getCategoryParent();
        //echo "<pre>";print_r($menu);
        if (count($cate) > 0):
            ?>
            <div class="control-group">
                <label class="control-label">Danh mục cha</label>
                <div class="controls">
                    <select id="category" name="SubCategory[category_id]">
                        <option value="">--</option>
                        <?php
                        foreach ($cate as $k => $m) {
                            if ($k == $model->id) {
                                echo "<option value='" . $k . "' selected='selected'>" . $cate[$k] . "</option>";
                            } else {
                                echo "<option value='" . $k . "'>" . $cate[$k] . "</option>";
                            }
                        }
                        ?>
                    </select>
                    <span class="help-inline"><?php echo $form->error($model, 'parent'); ?></span>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">Hình Đại Diện</label>
                <div class="controls">
                    <?php echo $form->fileField($model, 'cover_image', array('class' => 'id-input-file-1 span5')); ?>
                    <span class="help-inline" style="float:left;margin-left:390px;"><?php echo $form->error($model, 'cover_image'); ?></span>
                </div>
            </div>


            <div class="control-group">
                <div class="controls">
                    <?php
                    if ($model->cover_image) {
                        echo '<img src="' . Yii::app()->baseUrl . '/timthumb.php?src=' . Yii::app()->baseUrl . '/data/cover/' . $model->cover_image . '&h=75&w=75">';
                    }
                    ?>
                </div>
            </div>
        <?php endif; ?>

        <div class="control-group">
            <label class="control-label">Tên danh mục sản phẩm</label>
            <div class="controls">
                <?php echo $form->textField($model, "name", array('size' => 60, 'maxlength' => 100, 'class' => 'span5', 'placeholder' => 'Tên menu')); ?>
                <span class="help-inline"><?php echo $form->error($model, 'name'); ?></span>
            </div>
        </div>

        <div class="control-group">
            <label class="control-label">Trạng thái</label>
            <div class="controls">
                <?php echo $form->dropDownlist($model, "active", array('0' => 'Không kích hoạt', '1' => 'Kích hoạt')); ?>
                <span class="help-inline"><?php echo $form->error($model, 'active'); ?></span>
            </div>
        </div>
        <div class="clear"></div>
        <div class="form-actions">
            <button class="btn btn-info" type="submit">
                <i class="icon-ok bigger-110"></i>
                Submit
            </button>
        </div>
        <!--PAGE CONTENT ENDS-->
    </div><!--/.span-->
</div><!--/.row-fluid-->    
<?php $this->endWidget(); ?>